package cn.lili.controller.system;


import cn.lili.common.utils.ResultUtil;
import cn.lili.common.vo.PageVO;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.system.entity.dos.PackConfig;
import cn.lili.modules.system.entity.vo.PackConfigVO;
import cn.lili.modules.system.service.PackConfigService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 礼包配置
 */
@RestController
@RequestMapping("/system/pack/config")
@RequiredArgsConstructor
public class PackConfigController {

    private final PackConfigService packConfigService;

    /**
     * 查询礼包配置
     */
    @GetMapping("/page")
    public ResultMessage<Object> page(PageVO pageVO, PackConfigVO packConfigVO) {
        return packConfigService.pageVO(pageVO, packConfigVO);
    }

    /**
     * 新增礼包配置
     */
    @PostMapping("/save")
    public ResultMessage<Object> save(@RequestBody PackConfig packConfig) {
        packConfigService.saveCheck(packConfig);
        return ResultUtil.data(packConfigService.save(packConfig));
    }

    /**
     * 修改礼包配置
     */
    @PostMapping("/update")
    public ResultMessage<Object> update(@RequestBody PackConfig packConfig) {
        packConfigService.updateCheck(packConfig);
        return ResultUtil.data(packConfigService.updateById(packConfig));
    }

    /**
     * 删除礼包配置
     */
    @PostMapping("/delete/{id}")
    public ResultMessage<Object> delete(@PathVariable String id) {
        return ResultUtil.data(packConfigService.removeById(id));
    }
}
